#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

#define SQUARE(x) (x)*(x)
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define N 1001
int prime[N], i, j, n, m, cur;
void fill() {
	prime[0] = prime[1] = 0;
	for (i = 2; i < N; i++)
		prime[i] = 1;
	for (i = 2; i * i <= N; i++)
		if (prime[i])
			for (j = 2 * i; j < N; j += i)
				prime[j] = 0;
}
int main() {
	fill();
	for (scanf("%d", &n); n--;) {
		int s = 0;
		for (scanf("%d", &m); m--;) {
			scanf("%d", &cur);
			if (prime[cur])
				s += cur;
		}
		printf("%d\n", s);
	}
	return 0;
}
